#include<iostream>
#include<vector>
#include<queue>
#include<cstring>
#include<cmath>
#include<map>
#include<set>
#include<cstdio>
#include<algorithm>
#define debug(a) cout<<#a<<"="<<a<<endl;
using namespace std;
const int maxn=3e3+100;
typedef int LL;
LL dp[maxn][maxn];
char str[maxn];
int main(void)
{
  cin.tie(0);std::ios::sync_with_stdio(false);
  cin>>(str+1);
  LL length=strlen(str+1);
  memset(dp,0x3f,sizeof(dp));
  for(LL i=1;i<=length;i++){
    dp[i][i]=1;
  }
  for(LL len=2;len<=length;len++){
    for(LL l=1;l+len-1<=length;l++){
        LL r=l+len-1;
        LL flag=0;
        if(str[l]!=str[r]) flag=1;
        dp[l][r]=min(dp[l+1][r]+flag,dp[l][r-1]+flag);
    }
  }
  cout<<dp[1][length]<<endl;
return 0;
}
